package com.hongyuan.sellcoach.ui.home.activity;

import android.os.Bundle;

import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.mvvmhabitx.utils.ToastUtils;
import com.hongyuan.sellcoach.R;
import com.hongyuan.sellcoach.base.AppViewModelFactory;
import com.hongyuan.sellcoach.base.CustomActivity;
import com.hongyuan.sellcoach.data.Constants;
import com.hongyuan.sellcoach.data.md5.BaseUtil;
import com.hongyuan.sellcoach.databinding.ActivityCancelAppointmentBinding;
import com.hongyuan.sellcoach.ui.home.beans.HomeContentBean;
import com.hongyuan.sellcoach.ui.home.view_mode.CancelAppointmentViewMode;
import com.hongyuan.sellcoach.utils.CustomDialog;

import me.tatarka.bindingcollectionadapter2.BR;

public class CancelAppointmentActivity extends CustomActivity<ActivityCancelAppointmentBinding, CancelAppointmentViewMode> {

    private HomeContentBean.ListBean bean;

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_cancel_appointment;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public CancelAppointmentViewMode initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(CancelAppointmentViewMode.class);
    }

    @Override
    public void initParam() {
        super.initParam();

        bean = (HomeContentBean.ListBean) getBundle().getSerializable("stu");
    }

    @Override
    public void initView() {
        super.initView();

        setOnRefresh(binding.refresh,REFRESH_0X4);

        binding.comBack.setOnClickListener(view -> finish());

        viewModel.entity.set(bean);
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.uc.showEdit.observe(this, aVoid -> {
            CustomDialog.showTurnDowen(this, (v, message) -> {

                viewModel.setParams("cpa_id",String.valueOf(bean.getCpa_id()))
                        .setParams("bohui_note",message)
                        .requestData(Constants.JL_UN_AGREE_CANCEL);

            });
        });
    }
}
